<?php
use yii\widgets\LinkPager;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Json;
use backend\assets\AppAsset;
use yii\web\View;
?>
<style>
	table tbody tr th{text-align: center; background-color: #FC9D9A; color: #fff;}
	table tbody tr td{text-align: center;}
</style>
<div class="ibox-title">
	<h5>管理员列表</h5>
</div>

<div class="ibox-content timeline">
	<div class="box-create">
		<?= Html::a('添加管理员','addadmin',['class' => 'btn btn-primary langse'] ) ?>
	</div>
	<table class="table  table-bordered" style="background:#fff;margin-top:20px;"  align="center">
		<tr>
			<th>用户名</th>
			<th>电子邮箱</th>
			<th>IP地址</th>
			<th>登录时间</th>
			<th>创建时间</th>
			<th>操作</th>
		</tr>
		<?php  foreach($admin_data as $user){ ?>
		<tr class="tr<?=$user->id?>">
			<td class="center"><?=$user->username?></td>
			<td class="center"><?=$user->useremail ?></td>
			<td class="center"><?=long2ip($user->login_ip);?></td>
			<td class="center"><?=date('Y-m-d H:i:s', $user->login_time); ?></td>
			<td class="center"><?=date('Y-m-d H:i:s', $user->create_time); ?></td>
			<td class="center">
				<?= Html::a('编辑管理员', ['addadmin', 'uid' => $user->id ],[
					'data' => [
						'method' => 'post',
					],
					'class' => 'btn btn-info',
				])?>
	            <a class="btn btn-danger" href="javascript:void(0);" onclick="del(<?=$user->id?>)"  >
	                删除
	            </a>
	        </td>
		</tr>
	<?php } ?>
	</table>
</div>
<?php
$js = <<<Js
window.del = function ( id ){
		layer.confirm('你确定要删除此管理员？', function(){
			$.post('/item/del',{id:id}, function(data){
				if(data.status == 1){
					$('.tr'+id).remove();
				}
				layer.alert(data.message);
			})
		});
	}
Js;
$this->registerJs($js);
?>